
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n+1];//这个是关键一步，避免比较的时候数组越界，所以数组长度写为n+1;
        int i = 0;
        for (i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        int count = 0;
        i = 0;
       while(i < n) {
           if (array[i] > array[i + 1]) {
               while(i < n && array[i] > array[i + 1]) {
                   i++;
               }
               count++;
               i++;
           }else if (array[i] == array[i+1]) {
                   i++;
           }else  {
               while(i < n && array[i] < array[i + 1]) {
                   i++;
               }
               count++;
               i++;
           }

       }
        System.out.println(count);
    }
}